/**
 * @Title: SysLoginAction.java
 * @Package com.yly.system.login
 * @Description: TODO
 * @author zz
 * @date 2013-12-15 下午9:46:42
 * @version V1.0
 */
package com.yly.module.sys.home;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.yly.common.basic.action.BasicSupportAction;
import com.yly.utils.StrUtil;

import freemarker.template.TemplateException;

/**
 * @ClassName: SysLoginAction
 * @Description: TODO
 * @author zz
 * @date 2013-12-15 下午9:46:42
 */
@SuppressWarnings("serial")
@Results(value = {
		@Result(name = "sys_top", location = "/WEB-INF/page/sys/basic_frame/top.jsp"),
		@Result(name = "sys_left", location = "/WEB-INF/page/sys/basic_frame/left.jsp"),
		@Result(name = "sys_right", location = "/WEB-INF/page/sys/basic_frame/right_default.jsp"),
		@Result(name = "sys_channel", location = "/WEB-INF/page/common/include/channel.jsp"),
		@Result(name = "freemarker", type = "freemarker", location = "welcome.ftl") })
public class SysHomeAction extends BasicSupportAction {

	protected static Log loger = LogFactory.getLog(SysHomeAction.class);

	@Resource
	private ISysHomeService sysHomeServiceImpl;

	@SuppressWarnings("rawtypes")
	@Action("getTop")
	public String getTop() {
		loger.debug("加载后台主页顶部");
		Map map = this.sysHomeServiceImpl.getTop(param);
		this.putAll(map);
		return "sys_top";
	}

	@SuppressWarnings("rawtypes")
	@Action("getLeft")
	public String getLeft() {
		loger.debug("加载后台主页顶部");
		List list = this.sysHomeServiceImpl.getLeft(param);
		this.put("list", list);
		return "sys_left";
	}

	@SuppressWarnings("rawtypes")
	@Action("getRight")
	public String getRight() {
		loger.debug("获得后台主页内容部分");
		Map map = this.sysHomeServiceImpl.getRight(param);
		this.putAll(map);
		return "sys_right";
	}

	@SuppressWarnings("rawtypes")
	@Action("getChannel")
	public String getChannel() {
		loger.debug("获得后台主页快捷入口部分");
		List list = this.sysHomeServiceImpl.getChannel(param);
		this.put("list", list);
		return "sys_channel";
	}

	public void test() {

		Map root = new HashMap();

		root.put("user", "Big Joe");
		root.put("user1", "Big Joe1");
		root.put("user2", "Big Joe2");
		root.put("user3", "Big Joe3");

		this.putAll(root);

		try {
			this.createStaticPage("test.ftl", "abc/def/test_tag.html", root,
					"utf-8");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (TemplateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		loger.debug("test-e");
	}

	public ISysHomeService getSysHomeServiceImpl() {
		return sysHomeServiceImpl;
	}

	public void setSysHomeServiceImpl(ISysHomeService sysHomeServiceImpl) {
		this.sysHomeServiceImpl = sysHomeServiceImpl;
	}


}
